package com.yjhb.android.sbz.activity;

import android.content.Intent;
import android.text.TextUtils;
import android.widget.EditText;
import android.widget.TextView;

import com.yjhb.android.sbz.R;
import com.jojo.android.zxlib.base.mvp.BasePresenter;
import com.jojo.android.zxlib.tool.ZxToast;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 创建者 zx
 * 创建时间 2020/11/24 11:28
 */
public class ModifyActivity extends BaseActivity {
    private final String TAG = "ModifyActivity";

    @BindView(R.id.ed_modify)
    public EditText ed_modify;
    @BindView(R.id.title_tv)
    public TextView title_tv;

    private String target;


    @Override
    protected BasePresenter initPresenter() {
        return null;
    }

    @Override
    protected boolean isImmerse() {
        return true;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_modify;
    }

    @Override
    protected void initUI() {
        target = getIntent().getStringExtra("target");
        if (!TextUtils.isEmpty(target)) {
            ed_modify.setHint("请输入" + target);
            title_tv.setText("修改" + target);
        }
        ed_modify.requestFocus();
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void regEvent() {

    }


    @OnClick(R.id.fix_tv)
    public void fix_tv() {
        if (TextUtils.isEmpty(ed_modify.getText())) {
            ZxToast.showCenterToastLight(target + "不能为空");
            return;
        }
        Intent intent = new Intent();
        intent.putExtra("result", ed_modify.getText().toString());
        setResult(RESULT_OK, intent);
        finish();
    }

    @OnClick(R.id.back)
    public void back() {
        setResult(RESULT_CANCELED);
        finish();
    }
}
